<?php
/**
 * 微签到模块微站定义
 *
 * @author zhouziyuan
 * @url http://bbs.we7.cc/
 */
defined('IN_IA') or exit('Access Denied');

class Yuan_qiandaoModuleSite extends WeModuleSite {

	public function doMobileSign() {
		//这个操作被定义用来呈现 功能封面
		global $_W,$_GPC;
		$murl = MODULE_URL."template/mobile/";
		include $this->template('index2');
	}
	public function doWebHistory() {
		//这个操作被定义用来呈现 管理中心导航菜单
	    global $_W,$_GPC;
	    if(!$_GPC['operation']){
	        $historylist = pdo_fetchall("select a.id,a.borntime,b.name,b.daytime,b.point,c.nickname,c.avatar from ".tablename($this->modulename.'_history')." as a left join ".tablename($this->modulename.'_activity')." as b on a.getactid=b.id left join ".tablename('mc_members')." as c on a.uid=c.uid where a.weid=:weid order by a.borntime desc",array('weid'=>$_W['uniacid']));
	    }
	    elseif($_GPC['operation']=='delete'){
	        if(!$_GPC['id']){
	            message("id不能为空");
	        }
	        pdo_delete($this->modulename."_history",array('id'=>$_GPC['id']));;
	        message('记录删除成功',$this->createWebUrl('history'));
	    }
	    include $this->template('history');
	}
	public function doWebActivity() {
	    //这个操作被定义用来呈现 管理中心导航菜单
	    global $_W,$_GPC;
	    if(!$_GPC['operation']){
	        $activitylist = pdo_fetchall("select * from ".tablename($this->modulename.'_activity')." where weid=:weid order by point asc",array('weid'=>$_W['uniacid']));
	    }
	    elseif($_GPC['operation']=='add'){
	        if($_GPC['op']=='additem'){
	            if(!$_GPC['name']||!$_GPC['daytime']||!$_GPC['point']){
	                message("数据项不允许为空");
	            }
	            pdo_insert('yuan_qiandao_activity',array('weid'=>$_W['uniacid'],'name'=>$_GPC['name'],'daytime'=>$_GPC['daytime'],'point'=>$_GPC['point']));
	            header("Location: ".$this->createWebUrl('activity'));
	        }
	    }
	    elseif($_GPC['operation']=='update'){
	         
	        if(!$_GPC['id']){
	            message("id不能为空");
	        }
	         
	        if($_GPC['op']=='updateitem'){
	            pdo_update($this->modulename."_activity",array('name'=>$_GPC['name'],'daytime'=>$_GPC['daytime'],'point'=>$_GPC['point']),array('id'=>$_GPC['id']));
	            message('活动修改成功',$this->createWebUrl('activity'));
	        }
	        $activityitem = pdo_fetch("select * from ".tablename($this->modulename."_activity")." where id=:id",array('id'=>$_GPC['id']));
	    
	    }
	    elseif($_GPC['operation']=='delete'){
	        if(!$_GPC['id']){
	            message("id不能为空");
	        }
	        pdo_delete($this->modulename."_activity",array('id'=>$_GPC['id']));;
	        message('活动删除成功',$this->createWebUrl('activity'));
	    }
	    include $this->template('activity');
	}
}